import os

if __name__ == '__main__':
    # process each line
    with open('data/train.csv', 'r') as f_in:
        for line in f_in:
            # uuid, visit_time, user_id, item_id, features, label
            row = line.split(',')
            row[2], row[3] = row[3], row[2]
            with open('data/train_fixed.csv', 'a') as f_out:
                f_out.write(','.join(row))
    # rename files
    os.system('mv data/train.csv data/train_old.csv')
    os.system('mv data/train_fixed.csv data/train.csv')
